﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MathService.DSP.Signals.Interpolators
{
    [Serializable]
    public class Linear : Interpolator
    {
        public override double GetValue(double[] Values, double pos)
        {
            int x1 = (int)pos, x2 = x1 + 1;
            double y1 = Values[x1], y2 = Values[x2];
            double k = (y2 - y1) / (double)(x2 - x1);
            return k * (pos - (double)x1) + y1;
        }

        public override double SetValue(double[] Values, double pos, double Value)
        {
            throw new NotSupportedException();
        }
    }
}
